#pragma once
#include <src/math/CauchyProblems/all.h>
#include <utility>

template <class Cauchy_type>
std::pair<typename Cauchy_type::p_array_2,typename Cauchy_type::p_array_2> Cauchy_test (){
		std::cout << std::endl << " ---------------------------------------------------" << std::endl;
		std::cout << std::endl << " --------Starting a Cauchy_test-------" << std::endl;
		std::cout << std::endl << " example for " << typeid(Cauchy_type).name()<< std::endl << std::endl ;
		std::cout << std::endl << " solving a small equation... "<< std::endl;
		Cauchy_type cauchy;
		std::pair<typename Cauchy_type::p_array_2,typename Cauchy_type::p_array_2> result;
		result.first = cauchy.get_representation(); // initial data

		std::cout << std::endl << " ---" << cauchy.get_name() << "---" << std::endl;
		OS_double time_begin = cauchy.get_current_time();
		OS_double time_end = time_begin + 1. ;
		cauchy.insert_time(time_end);
		for (;time_begin < time_end; time_begin = ++ cauchy ) {
			std::cout << " Time =  " << time_begin << "   ";
//			std::cout << " solution =  " << cauchy.get_solution() << std::endl;
		};
		std::cout << " End Time =  " << time_begin << std::endl;
		std::cout << " Solution is  " << cauchy.get_solution()<< std::endl;
		std::cout << std::endl << " testing graph  "<< std::endl;
		std::cout << std::endl << cauchy.get_graph()<< std::endl;

		std::cout << std::endl << " testing representation "<< std::endl;
		std::cout << std::endl << cauchy.get_representation()<< std::endl;

		std::cout << std::endl << " -------Ending Cauchy_D__x_example-----" << std::endl;
		std::cout << std::endl << " -------Ending returning 2D representation of the solution-----" << std::endl;
		std::cout << std::endl << " ---------------------------------------------------" << std::endl;
		result.second = cauchy.get_representation(); // final solution
		return result;
};

template <class Cauchy1, class Cauchy2> 
void check_cauchy_data () {
		std::pair<typename Cauchy1::p_array_2,typename Cauchy1::p_array_2> p_mod1 = Cauchy_test<Cauchy1>();
		std::pair<typename Cauchy2::p_array_2,typename Cauchy2::p_array_2> p_mod2 = Cauchy_test<Cauchy2>();

		bool logical = p_mod1.first == p_mod2.first;
		OS_DYNAMIC_CHECK(logical == true, "check_cauchy_data : initial data are not the same ");

		logical = p_mod1.second == p_mod2.second;
		OS_DYNAMIC_CHECK(logical == true, "check_cauchy_data : Cauchy problems gives different solutions with the same initial data");
};


void CauchyProblems_test();
